package com.bleeth.flow.step.row;

import com.bleeth.flow.core.common.APlugin;
import com.bleeth.flow.core.common.PluginAnnotation;
import com.bleeth.flow.core.common.PluginTypeEnum;
import com.jd.platform.async.wrapper.WorkerWrapper;
import lombok.Data;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @author ：Bleeth
 * @date ：2021-08-06
 * @description：去重组件
 */
@Data
@PluginAnnotation(name = "去重组件",
        type = PluginTypeEnum.ROW,
        description = "",
        id = "DuplicatePlugin")
public class DuplicatePlugin extends APlugin implements Serializable {

    private static final long serialVersionUID = 8590466403179585444L;


    private List<String> colList;



    @Override
    public Dataset<Row> action(Dataset<Row> param, Map<String, WorkerWrapper> allWrappers) {
        super.action(param, allWrappers);


        String fromPluginName = fromList.get(0);
        WorkerWrapper fromWrapper = allWrappers.get(fromPluginName);
        Dataset<Row> ds = (Dataset<Row>) fromWrapper.getWorkResult().getResult();


        return ds;
    }


}
